import matplotlib.pyplot as plt
import  os
from PIL import Image
import imagesize
import cv2

arr = [0,1,2,4,6]
for i in range(len(arr)):
    root_path = "G:\Desktop\搅拌站文件\Material_level\yunnan_data\orin_data\\1224"
    save_root_path = "G:\Desktop\搅拌站文件\Material_level\yunnan_data_crop\\1224"
    print(str(i))
    root_path = os.path.join(root_path,str(arr[i]))
    save_root_path = os.path.join(save_root_path,str(arr[i]))
    print(root_path,"\t",save_root_path)
    img_name = sorted(os.listdir(root_path))
    for j in range(len(img_name)):
        print(img_name[j])
        img_path = os.path.join(root_path,img_name[j])
        image = Image.open(img_path)
        img = image.crop((80,0,560,480))# x,y,x+w,y+h
        save_img_path = img_name[j]
        print(os.path.join(save_root_path,save_img_path))
        img.save(os.path.join(save_root_path,save_img_path))